#include <iostream>
#include <vector>
using namespace std;
 
int getCount(vector<int> &temp)
{
    int n = temp.size();
    vector<int>dp(n + 1, 1000);
    dp[0] = 1;
    for(int i = 1; i <= n; i ++){
        for(int j = i - 1; j >= 0; j --){
            if(dp[j] == 0)continue;
            if(j + temp[j] >= i)dp[i] = min(dp[i], dp[j]+1);
        }
    }
    if(dp[n] == 1000)return -1;
    else return dp[n]-1;
}
 
int main(){
    int N;
    int s; 
    cin >> N;
    vector<int>temp(N , 0);
    for(int i = 0; i < N; i ++)
        cin >> temp[i];
    cout << getCount(temp) << endl;
    return 0;
}